use criterion::{black_box, criterion_group, criterion_main, Criterion};
use binary_heap::binary_heap::{BinaryHeap, BinaryHeapType};

fn binary_heap_insert_benchmark(c: &mut Criterion) {
    let mut heap = BinaryHeap::new(BinaryHeapType::Min, |a: &i32, b: &i32| a.cmp(b));
    c.bench_function("binary_heap_insert", |b| b.iter(|| {
        heap.insert(black_box(10));
    }));
}

fn binary_heap_pop_benchmark(c: &mut Criterion) {
    let mut heap = BinaryHeap::new(BinaryHeapType::Min, |a: &i32, b: &i32| a.cmp(b));
    for i in 0..1000 {
        heap.insert(i);
    }
    c.bench_function("binary_heap_pop", |b| b.iter(|| {
        heap.pop();
    }));
}

fn binary_heap_num_entries_benchmark(c: &mut Criterion) {
    let mut heap = BinaryHeap::new(BinaryHeapType::Min, |a: &i32, b: &i32| a.cmp(b));
    for i in 0..1000 {
        heap.insert(i);
    }
    c.bench_function("binary_heap_num_entries", |b| b.iter(|| {
        heap.num_entries();
    }));
}

criterion_group!(
    benches,
    binary_heap_insert_benchmark,
    binary_heap_pop_benchmark,
    binary_heap_num_entries_benchmark
);
criterion_main!(benches);